<script setup>
import {infoStore} from "@/stores";
import {reactive, toRefs} from "vue";
import {useRouter} from "vue-router";
import NavBar from "@/components/NavBar.vue";
import {showToast} from "vant";

const store = infoStore()
const {addressList} = toRefs(store)
const dataOptions = reactive({
    id: 'id',
    addressDetail: 'fullAddress',
    addressName: 'customerName'
});
const state = reactive({
    title: '地址列表'
})
const userRouter = useRouter()
const clickItem = () => {
    showToast('下单成功')
    setTimeout(() => {
        userRouter.push('/detail')
    }, 300)
}
const delClick = () => {
    userRouter.push('/editAddress')
}
const editClick = () => {
    userRouter.push('/editAddress')
}
const add = () => {
    userRouter.push('/addAddress')
}
</script>

<template>
    <NavBar :title="state.title"/>
    <nut-address-list
        :data="addressList"
        @click-item="clickItem"
        @del-icon="delClick"
        @edit-icon="editClick"
        @add="add"
        :show-bottom-button="true"
        :data-options="dataOptions"
    >
    </nut-address-list>
</template>

<style scoped lang="less">

</style>